package myself.study.network.udp.examples.chatroom;

import java.net.DatagramSocket;
import java.net.SocketException;

/**
* @Name: ChatRoom
* @Description: udp案例程序：聊天室，通过多线程改进聊天程序，从而实现在一个窗口发送和接收数据
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-1-12 上午10:08:32 
* @Version: V1.0
 */
public class ChatRoom {
	
	public static void main(String[] args) throws SocketException {
		//创建发送端Socket对象
		DatagramSocket clientSocket = new DatagramSocket() ;
		//创建接收端Socket对象
		DatagramSocket serverSocket = new DatagramSocket(10086) ;
		//创建发送端线程对象
		SendRunnable sr = new SendRunnable(clientSocket) ;
		//创建服务端线程对象
		ReceiveRunnable rr = new ReceiveRunnable(serverSocket) ;
		//创建执行线程，执行发送端、服务端线程代码
		Thread t1 = new Thread(sr) ;
		Thread t2 = new Thread(rr) ;
		t1.start() ;
		t2.start() ;
	}

}
